<template>
  <view>
    <view class="class-box top-list">
      <view class="class-title">
        <view class="title-box">
          <view class="class-msg">
            <view class="text1">推荐热门圈子话题</view>
            <view class="class-msg-xian"></view>
          </view>
        </view>
      </view>
      <view>
        <view class="topic-item" v-for="item in recommentTopicList" @click="toDetails(item.id)">
          <view class="topic-box">
            <view class="topic-top">
              <view class="image"><image mode="aspectFill" :src="item.thumb"></image></view>
              <view class="topic-info">
                <view class="titles">{{item.title}}</view>
                <view class="tag" v-if="item.cateNames">
                  <text v-for="i in (item.cateNames.split('、'))">{{i}}</text>
                </view>
                <view class="userCount">{{item.joinNum}}参与</view>
              </view>
            </view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      recommentTopicList:[]
    };
  },
  created() {
    this.getRecommentTopic()
  },
  methods:{
    // 获取热门话题推荐
    async getRecommentTopic()
    {
      let postData={page:1,pageSize:3}
      let {data} =await this.$javaCircle.doRequest("post",'circle/customer/topic/getRecommentTopic',postData,'json',false)
      this.recommentTopicList=this.recommentTopicList.concat(data.data.list.map(item=>{
        item.cateNames=item.cateNames.substring(0,14)
        return item
      }))
    },
    toDetails(id)
    {
      uni.navigateTo({url:"/pages/circle/details/details?id="+id})
    },
  }
}
</script>

<style lang="scss">
.topic-box{
  padding: 0;
  margin-bottom: 40upx;
  background-color: #fff;
  box-sizing: border-box;
  position: relative;
  .topic-top{
    width: 100%;
    display: flex;
    .image{
      width: 140upx;
      height: 140upx;
      border-radius: 8upx;
      background-color: #666666;
      margin-right: 20upx;
      image{
        width: 100%;
        height: 100%;
        border-radius: 8upx;
      }
    }
    .topic-info{
      flex: 1;
      .titles{
        width: 490upx !important;
        font-size: 42upx;
        color: #000 !important;
        font-weight: 500;
        margin-bottom: 8upx;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
      .tag{
        width: 490upx;
        overflow: hidden;
        white-space: nowrap;
        margin-bottom: 8upx;
        text{
          background-color: #F1FAF3;
          color: #6AAC80;
          font-size: 30upx;
          box-sizing: border-box;
          padding: 0 8upx;
          border-radius: 8upx;
          margin-right: 12upx;
        }
      }
      .tag::after {
        content: "...";
        display: inline-block;
        background-color: #F1FAF3;
        width: 0;
        color: #6AAC80;
      }
      .userCount{
        font-size: 28upx;
        color: #999999;
      }
    }
  }
  .source{
    width: 400upx;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 28upx;
    color: #999999;
    margin-top: 12upx;
  }
  .button{
    position: absolute;
    width: 190upx;
    height: 68upx;
    border-radius: 39upx;
    background-color: #54B174;
    color: #fff;
    line-height: 68upx;
    text-align: center;
    font-size: 36upx;
    font-weight: 500;
    right: 20upx;
    top: 150upx;
  }
  .desc{
    width: 100%;
    font-size: 38upx;
    color: #666666;
    margin-top: 18upx;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .buttons{
    width: 100%;
    border-top: 1upx solid #D8D8D8;
    height: 98upx;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 31upx;
    .button-item{
      width: 30%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 26upx;
      color: #666;
      image{
        width: 52upx;
        height: 52upx;
      }
    }
  }
}
.class-box{
  width: 100%;
  box-sizing: border-box;
  padding: 30upx;
  background: #fff;
}
.class-title{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 30upx;
}
.title-box{
  display: flex;
  align-items: center;
}
.class-title .class-icon{
  width: 41upx;
  height: 40upx;
  margin-right: 19upx;
  image{
    width: 100%;
    height: 100%;
  }
}
.class-msg{
  height: 40upx;
  position: relative;
  width: 400upx;
  .text1{
    line-height: 40upx;
    position: absolute;
    font-size: 40upx;
    color: #333;
    font-weight: 600;
    z-index: 2;
    top: 0;
    left: 0;
  }
  .class-msg-xian{
    z-index: 1;
    position: absolute;
    left: 0;
    bottom: 0upx;
    width: 118upx;
    height: 8upx;
    background: linear-gradient(to right, #FD9A00 0%, #fff 100%);
  }
}
.class-title .msg{
  font-size: 28upx;
  color: #585858;
  text-decoration: underline;
}
</style>
